CREATE TABLE [dbo].[tb_ObjetosDeInspeccion]
(
[idObjetoInspeccion] [int] NOT NULL IDENTITY(1, 1),
[Descripcion] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[updateObjetos] ON [dbo].[tb_ObjetosDeInspeccion] 
FOR UPDATE
AS
if (update(idInspeccion)) begin
	UPDATE tb_Inspecciones
	SET TipoObjetoInspeccion = (SELECT idInspeccion from inserted)
	WHERE TipoObjetoInspeccion in (SELECT idInspeccion from deleted)

	UPDATE tb_Reparaciones
	SET TipoObjetoReparacion = (SELECT idInspeccion from inserted)
	WHERE TipoObjetoReparacion in (SELECT idInspeccion from deleted)

end
GO
ALTER TABLE [dbo].[tb_ObjetosDeInspeccion] ADD CONSTRAINT [PK_tb_ObjetosDeInspeccion] PRIMARY KEY NONCLUSTERED  ([idObjetoInspeccion]) ON [PRIMARY]
GO
